package com.yoda.controller.user;

import com.yoda.dto.RegDto;
import com.yoda.result.Result;
import com.yoda.service.IYddUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("userIndexController")
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IYddUserService userService;

    @GetMapping("/index")
    public Result index(){
        return userService.index();
    }

    /**
     * 热门置顶文章数据
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("/new")
    public Result indexNew(@RequestParam(value = "page")String page,@RequestParam(value = "limit") String pageSize){
        return userService.indexNew(page,pageSize);
    }

    /**
     *  最新文章
     * @return
     */
    @GetMapping("/hot")
    public Result indexHot(){
        return userService.indexHot();
    }

    @GetMapping("/recommend")
    public Result recommend(){
        return userService.indexHot();
    }

    /**
     * 注册
     * @param dto
     * @return
     */
    @PostMapping("/reg")
    public Result reg(@RequestBody RegDto dto){
        return userService.reg(dto);
    }

    @GetMapping("/show")
    public Result show(@RequestParam Integer id){
        return userService.show(id);
    }

    @GetMapping("/list")
    public Result getlist(@RequestParam(value = "page")String page,
                       @RequestParam(value = "limit") String pageSize,
                       @RequestParam(value = "cateid") String cateid){
        return userService.getlist(page,pageSize,cateid);
    }

}
